package servlet.PropertyManagementModule.equipmentMaintenance;

import bean.pojo.Maintenance;
import com.alibaba.fastjson2.JSONObject;
import commons.baseServlet.BaseServlet;
import commons.r.R;
import service.EquipmentMaintenanceService;
import service.impl.EquipmentMaintenanceServiceImpl;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;

/**
 * servlet.PropertyManagementModule.equipmentMaintenance
 * User: xlh
 * Date: 2024/12/20 18:43
 * motto:推到高塔
 * Description:
 * Version: V1.0
 */@WebServlet(value = "/peopleEquipmentMaintenance/*")
public class PeopleEquipmentMaintenanceServlet extends BaseServlet {
    public R createMaintenance(HttpServletRequest request){
        try {
            BufferedReader bufferedReader=request.getReader();
            String data=bufferedReader.readLine();
            Maintenance maintenance= JSONObject.parseObject(data,Maintenance.class);
            EquipmentMaintenanceService equipmentMaintenanceService=new EquipmentMaintenanceServiceImpl();
            boolean t=equipmentMaintenanceService.createMaintenance(maintenance);
            return t?R.ok("修改成功"):R.ok("修改失败");
        } catch (
                IOException e) {
            e.printStackTrace();
        }
        return R.error("添加出错");
    }
}
